using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace BootyBay.Models.Mapping
{
    public class ApplicationVersionInfoMap : EntityTypeConfiguration<ApplicationVersionInfo>
    {
        public ApplicationVersionInfoMap()
        {
            // Primary Key
            this.HasKey(t => t.Id);

            // Properties
            this.Property(t => t.IdentityName)
                .IsRequired()
                .HasMaxLength(500);

            this.Property(t => t.Version)
                .IsRequired()
                .HasMaxLength(500);

            this.Property(t => t.Publisher)
                .IsRequired()
                .HasMaxLength(500);

            this.Property(t => t.DisplayName)
                .IsRequired()
                .HasMaxLength(500);

            this.Property(t => t.PublisherDisplayName)
                .IsRequired()
                .HasMaxLength(500);

            this.Property(t => t.ChangeLog)
                .IsRequired();

            this.Property(t => t.LogoUrl_Store)
                .HasMaxLength(500);

            this.Property(t => t.ProtocolUrl)
                .HasMaxLength(50);

            this.Property(t => t.LogoUrl_150x150)
                .HasMaxLength(500);

            this.Property(t => t.LogoUrl_30x30)
                .HasMaxLength(500);

            this.Property(t => t.LogoUrl_310x150)
                .HasMaxLength(500);

            this.Property(t => t.LogoUrl_310x310)
                .HasMaxLength(500);

            this.Property(t => t.LogoUrl_70x70)
                .HasMaxLength(500);

            // Table & Column Mappings
            this.ToTable("ApplicationVersionInfo");
            this.Property(t => t.Id).HasColumnName("Id");
            this.Property(t => t.Id_ApplicationInfo).HasColumnName("Id_ApplicationInfo");
            this.Property(t => t.IdentityName).HasColumnName("IdentityName");
            this.Property(t => t.Version).HasColumnName("Version");
            this.Property(t => t.Publisher).HasColumnName("Publisher");
            this.Property(t => t.DisplayName).HasColumnName("DisplayName");
            this.Property(t => t.PublisherDisplayName).HasColumnName("PublisherDisplayName");
            this.Property(t => t.Description).HasColumnName("Description");
            this.Property(t => t.ChangeLog).HasColumnName("ChangeLog");
            this.Property(t => t.IsInPublicWindowsStore).HasColumnName("IsInPublicWindowsStore");
            this.Property(t => t.Category).HasColumnName("Category");
            this.Property(t => t.Subcategory).HasColumnName("Subcategory");
            this.Property(t => t.LogoUrl_Store).HasColumnName("LogoUrl_Store");
            this.Property(t => t.ProtocolUrl).HasColumnName("ProtocolUrl");
            this.Property(t => t.OperationDate).HasColumnName("OperationDate");
            this.Property(t => t.Keywords).HasColumnName("Keywords");
            this.Property(t => t.ScreenshotUrls).HasColumnName("ScreenshotUrls");
            this.Property(t => t.LogoUrl_150x150).HasColumnName("LogoUrl_150x150");
            this.Property(t => t.LogoUrl_30x30).HasColumnName("LogoUrl_30x30");
            this.Property(t => t.LogoUrl_310x150).HasColumnName("LogoUrl_310x150");
            this.Property(t => t.LogoUrl_310x310).HasColumnName("LogoUrl_310x310");
            this.Property(t => t.LogoUrl_70x70).HasColumnName("LogoUrl_70x70");

            // Relationships
            this.HasRequired(t => t.ApplicationInfo)
                .WithMany(t => t.ApplicationVersionInfoes)
                .HasForeignKey(d => d.Id_ApplicationInfo);

        }
    }
}
